package kr.momo.tmaker 
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author momo
	 */
	public class TMakerView extends Sprite 
	{
		private var transController:TransController;
		private var designItemLayer:Sprite;
		private var controllerLayer:Sprite;
		private var UILayer:Sprite;
		
		public function TMakerView() 
		{
			designItemLayer = new Sprite();
			addChild( designItemLayer );
			
			controllerLayer = new Sprite();
			addChild( controllerLayer );
			
			UILayer = new Sprite();
			addChild( UILayer );
			
			transController = new TransController();
			controllerLayer.addChild( transController );
			
			var testItem:DesignItem = new DesignItem( new DesignItem_RedJelly() );
			testItem.x = 100;
			testItem.y = 100;
			testItem.rotation = 40;
			
			var testItem1:DesignItem = new DesignItem( new DesignItem_RedJelly() );	
			
			addItem( testItem );
			addItem( testItem1 );
		}
		
		public function addItem( displayObject:DisplayObject ):void {
			designItemLayer.addChild( displayObject );
			
			displayObject.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler );
		}
		
		private function mouseDownHandler(e:MouseEvent):void 
		{
			transController.targetObject = e.currentTarget as DesignItem;
			transController.mouseDown();
		}
		
	}

}